package com.haixiaoke.saas.order.state.role;

import com.haixiaoke.saas.common.enums.OrderStateEnum;
import com.haixiaoke.saas.order.domain.Order;
import com.haixiaoke.saas.order.state.server.IOrderStateServerRole;

/**
 * 退房中状态服务实现类
 * @author panda
 * @Date 2024/4/30
 **/
public class CheckingOutOrderStateServerRole extends AbstractSpecificOrderOrderStateServerRole {
    public CheckingOutOrderStateServerRole(IOrderStateServerRole stateServerRole) {
        super(stateServerRole);
    }

    @Override
    public int orderCompletion(Order order, String recordSource, Long operatorId) {
        addOrderStateRecord(order.getOrderId(), order.getOrderState(), OrderStateEnum.ORDER_STATE_COMPLETED.getValue(), recordSource, operatorId);
        order.setOrderState(OrderStateEnum.ORDER_STATE_COMPLETED.getValue());
        return orderService.updateOrderBySystem(order);
    }
}
